import http from '@/utils/http';
import {postAjax} from '@/utils/axios';



/**
 * 删除区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const removeSubStructure = (params: any) => {
  return http.delete('bus/subStructure/remove', {params});
}

/**
 * 获取系统用户列表
 * @param params
 * @returns {*|Promise<any>}
 */
export const getSubStructureList = (params?: any) => {
  return http.get('bus/subStructure/list', {params});
}


/**
 * 获取系统用户列表
 * @param params
 * @returns {*|Promise<any>}
 */
export const queryLastData = (params?: any) => {
  return http.get('bus/subStructure/queryLastData', {params});
}


/**
 * 获取系统用户列表
 * @param params
 * @returns {*|Promise<any>}
 */
export const surveyByStructureId = (params?: any) => {
  return http.get('bus/subStructure/surveyByStructureId', {params});
}


/**
 * 保存修改区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const updateSubStructure = (params: any) => {
  return http.put('bus/subStructure/edit', params);
}

/**
 * 保存新增区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const addSubStructure = (params: any) => {
  return http.post('bus/subStructure/add', params);
}

/**
 * 保存新增区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const addSubStructureJson = (params: any) => {
  return postAjax('bus/subStructure/addJson', params);
}

/**
 * 通过id获取区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const getSubStructureById = (params: any) => {
  return http.get('bus/subStructure/' + params.id);
}

/**
 * 通过id获取区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const getCommonTitle = (params: any) => {
  return http.get('bus/subStructure/getCommonTitle/' + params.id);
}

export const queryByStructureId = (params: any) => {
  return http.get('bus/subStructure/queryByStructureId?id=' + params.id);
}

/**
 * 验证区域名称是否唯一
 * @param params
 * @returns {*|Promise<any>}
 */
export const checkSubStructureNameUnique = (params: any) => {
  params.loading = false;
  return http.post('bus/subStructure/checkNameUnique', params);
}

